<?php session_start();
/**
* @package		ReservatieComponent voor ouderavonden van Atheneum Alicebourg Lanaken.
* @copyright	Copyright (C) 2008 Kristof Beckers. All rights reserved.
* @Version		0.1
* @license		GNU/GPL, see LICENSE.php
**/
include ("../include/config.php");
require_once ("../include/db.php");
// username and password sent from form
$myusername=$_POST['username'];
$mypassword=$_POST['passwd'];

$sql="SELECT * FROM jos_reservatie_user WHERE username='$myusername' AND password='$mypassword' ";
$result=mysql_query($sql);

while ($row = mysql_fetch_array($result)) {
   $username =  $row['username'];  
   $password = $row['password'];
   $usernameid = $row['ID'];
   $klas = $row['klas'];
}

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
$_SESSION['myusername'] = $myusername ;
$_SESSION['klas'] = $klas;

if ($_SESSION['myusername'] == $admin){
	header("location:../admin/index.php");
	}
header("location:../reservatie.php");
}


else 

{
echo "Wrong Username or Password";
}
mysql_close();
?>